import { put, takeEvery } from "@redux-saga/core/effects";
import axios from "axios";
import { API } from "../../config";
import { getCategorySuccess, GET_CATEGORY } from "../actions/category.action";
import { Category } from "../models/category";

export default function* categorySaga() {
    yield takeEvery(GET_CATEGORY, function* () {
        const {data} = yield axios.get<Category[]>(`${API}/categories`)
        yield put(getCategorySuccess(data))
    })
}